<template>
  <view class="page-container" :style="{ paddingTop: safeTop + 'px' }">
    <view class="user-profile">
      <image class="avatar" :src="driverInfo.avatar" mode=""></image>
      <text class="username">{{ driverInfo.name }}</text>
      <text class="no">司机编号：{{ driverInfo.number }}</text>
      <text class="mobile">手机号码：{{ driverInfo.phone }}</text>
    </view>
    <view class="month-overview">
      <view class="title">我的任务</view>
      <view class="content">
        <view class="item">
          <text class="volumn">{{ taskPortInfo.taskAmounts }}</text>
          <text class="label">任务总量</text>
        </view>
        <view class="item">
          <text class="volumn">{{ taskPortInfo.completedAmounts }}</text>
          <text class="label">完成任务量</text>
        </view>
        <view class="item">
          <text class="volumn">{{ taskPortInfo.transportMileage }}</text>
          <text class="label">运输里程(km)</text>
        </view>
      </view>
    </view>
    <view class="entry-list">
      <uni-list :border="false">
        <uni-list-item
          to="/subpkg_user/truck/index"
          showArrow
          title="车辆信息"
        />
        <uni-list-item
          to="/subpkg_user/task/index"
          showArrow
          title="任务数据"
        />
        <uni-list-item
          to="/subpkg_user/settings/index"
          showArrow
          title="系统设置"
        />
      </uni-list>
    </view>
  </view>
</template>

<script>
import { getDriverUserApi, getTaskPortApi } from '@/utils/my'
import { systemMixin } from '@/store/mixinVuex.js'
export default {
  mixins: [systemMixin],
  data () {
    return {
      driverInfo: {},
      taskPortInfo: {},
    }
  },
  onLoad () {
    this.getDriverUser()
    this.getTaskPort()
  },
  onShow () {},

  methods: {
    async getDriverUser () {
      const { data } = await getDriverUserApi()

      this.driverInfo = data
    },
    async getTaskPort () {
      try {
        const { data, code } = await getTaskPortApi()
        if (code !== 200) {
          return uni.utils.toast()
        }
        this.taskPortInfo = data
      } catch (error) {
        console.log(error)
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.page-container {
  /* #ifdef H5 */
  height: calc(100vh - 50px);
  /* #endif  */
}

.user-profile {
  height: 600rpx;
  //   padding-top: env(safe-area-inset-top);
  background-image: url(https://sl-driver.oss-cn-hangzhou.aliyuncs.com/images/profile-bg%402x.png);
  background-size: 100% 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #fff;
  line-height: 1.8;
  font-size: 30rpx;

  .avatar {
    width: 140rpx;
    height: 140rpx;
    margin-top: 90rpx;
    border-radius: 50%;
    border: 6rpx solid rgba(255, 255, 255, 0.4);
  }

  .username {
    font-size: 36rpx;
    margin: 10rpx 0;
  }
}

.month-overview {
  height: 268rpx;
  margin: 0 30rpx;
  border-radius: 16rpx;
  background-color: #fff;
  position: relative;
  top: -130rpx;

  .title {
    color: #818181;
    font-size: 12px;
    padding-top: 28rpx;
    text-align: center;

    &::after,
    &::before {
      content: '-';
      margin: 0 5rpx;
    }
  }

  .content {
    display: flex;
    justify-content: space-around;
    text-align: center;
    font-size: 12px;
    color: #2a2929;
    margin-top: 40rpx;

    .volumn {
      display: block;
      font-size: 36rpx;
      margin-bottom: 20rpx;
      font-weight: 500;
    }
  }
}

.entry-list {
  margin: -100rpx 30rpx 0;
  border-radius: 16rpx;
  overflow: hidden;
}
</style>
